<template>
	<view>
		<!-- 当前余额 -->
		<!-- <view class="now-money"> 
			<text>余额：</text>
			<text class="money-num">{{yprice}}</text>
		</view> -->
		<view class="form-group">
			<view class="form-item">
				<view>收款人</view>
				<input type="text" placeholder="请输入收款人" v-model="form.tranuser"/>
			</view>
			<view class="form-item">
				<view>钱包账户</view>
				<view>
					<!-- <text :class="acc_index == key ? 'type-acc type-active' : 'type-acc'" v-for="(item,key) in acc_type" @tap="acc_index = key" v-if="key != zhongzi">{{item}}</text> -->
					<text :class="acc_index == key ? 'type-acc type-active' : 'type-acc'" v-for="(item,key) in acc_type" @tap="acc_index = key" v-if="item.state == 1">{{item.name}}</text>
				</view>
			</view>
			<view class="form-item">
				<view>金额</view>
				<input type="number" placeholder="请输入转账金额" v-model="form.price"/>
			</view>
			<view class="form-item">
				<view>二级密码</view>
				<input type="password" placeholder="请输入二级密码"v-model="form.pwd1" />
			</view>
			<view  class="form-item">
				<button @tap="submit">立即转账</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				form:{
					pwd1 : '',
					price : '',
					tranuser : ''
				},
				yprice : 0,
				acc_type : ['净资产','ZSDT','种子币'],
				acc_index : 0,
				zhongzi : -1,
			}
		},
		onLoad(e) {
			this.form.tranuser = e.username;
			if(e.username){
				this.zhongzi = 2;
			}
			this.getData();
		},
		methods:{
			submit(){
				if(!this.form.tranuser)return this.toasts('请输入收款人');
				if(!this.form.price)return this.toasts('请输入转账额度');
				if(!this.form.pwd1)return this.toasts('请输入二级密码');
				this.form.type = this.acc_index;
				this.ajax('user/transferdo',{
					data:this.form,
					success:(res)=>{
						res = res.data;
						this.toasts(res.info);
						if(res.status){
							this.yprice = 0;
							this.getData();
							this.form = {
								pwd1 : '',
								price : '',
								tranuser : ''
							};
						}
					}
				});
			},
			//获取页面数据
			getData(){
				this.ajax('user/sta',{
					data:{},
					success:(res) => {
						res = res.data;
						this.acc_type = res.info;
						for(var index in res.info) {
							if(res.info[index].state == 1) {
								this.acc_index = index;
								break;
							}
						}
					}
				});
			}
		}
	}
</script>

<style>
	.now-money{background-color: #409EFF;height:150upx;color:#FFFFFF;text-align: center;line-height: 150upx;font-size: 30upx;}
	.money-num{font-size: 60upx;}
	.form-group{width: calc(100% - 40upx);padding:20upx;background: #FFFFFF;}
	.form-item{height: 100upx;line-height: 80upx;margin-bottom: 20upx;}
	.form-item view{width:140upx;height:100%;font-size: 30upx;color:#666666;float: left;}
	.form-item input,.form-item>view:last-child{width: calc(100% - 180upx);border-bottom: 1upx solid #CCCCCC;height:70upx;padding-left: 20upx;font-size: 30upx;float: left;marign-top:80upx;border-radius: 5upx;}
	.form-item button{height:80upx;line-height: 80upx;background: #409EFF;color:#FFFFFF;border:none}
	.type-acc{padding:3upx 20upx;border:1upx solid #409EFF ;font-size: 30upx;margin-right: 20upx;}
	.type-active{background: #409EFF;color:#fff;}
</style>
